package com.yuan.department.service.impl;

import com.yuan.department.dao.IBaseDao;
import com.yuan.department.service.IBaseService;

import java.sql.SQLException;
import java.util.List;


/**
 * @program: Train
 * @description:
 * @author: yuan_boss
 * @create: 2022-11-23 18:19
 **/
public abstract class BaseServiceImpl<T> implements IBaseService<T> {
    public abstract IBaseDao<T> getBaseDao();

    @Override
    public boolean save(T t) throws SQLException {
        return getBaseDao().insert(t) > 0;
    }

    @Override
    public boolean update(T t) throws SQLException {
        return getBaseDao().updateById(t) > 0;
    }

    @Override
    public boolean remove(Integer id) throws SQLException {
        return getBaseDao().deleteById(id) > 0;
    }

    @Override
    public T queryById(Integer id) throws SQLException {
        return getBaseDao().selectById(id);
    }

    @Override
    public List<T> list() throws SQLException {
        return getBaseDao().selectList();
    }
}
